﻿using System.Linq;
using System.Windows.Controls;
using System.Windows.Input;
using Microsoft.Phone.Controls;

namespace WindowsPhone7InputScopes
{
    public partial class MainPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
            InputScopeNameList.ItemsSource = EnumHelper.GetNames<InputScopeNameValue>().OrderBy(f=>f);
        }

        private void InputScopeNameList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            InputScopeText.InputScope = new InputScope()
            {
                Names = { new InputScopeName() { NameValue = EnumHelper.GetValue<InputScopeNameValue>(InputScopeNameList.SelectedItem.ToString())} }
            };
            InputScopeText.Text = string.Empty;
            InputScopeText.Focus();
        }
    }
}
